#include "CocosPCH.h"
#include "Particle2DViewer.h"

Particle2DViewer::Particle2DViewer()
{
    m_bHasExportOne = false;
    m_bHasExportAll = false;
}

ui::Widget* Particle2DViewer::createItem(int nIndex, std::string strName)
{
    auto button = ui::Button::create("Button_Normal.png");
    button->setContentSize(Size(104, 40));
    button->setScale9Enabled(true);
    button->setTitleText(strName);
    button->setTitleFontSize(15);
    button->setTitleColor(Color3B(0, 0, 0));

    return button;
}

bool Particle2DViewer::LoadFile(std::string strPath)
{
    ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(strPath);
    Value &startParticleSizeValue = dict["startParticleSize"];
    if (startParticleSizeValue.isNull())
        return false;

    ParticleSystemQuad *pParticle = ParticleSystemQuad::create(dict);
    if (!pParticle)
        return false;

    BaseViewer::LoadFile(strPath);

    m_pViewNode->addChild(pParticle);

    return true;
}